class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int ans = 0;
        for(int i = 0; i < 32; i++){
            int temp_bit = 0;
            for(int j = 0; j < nums.size(); j++){
                temp_bit += (nums[j] >> i) & 1;
            } 
            temp_bit %= 3;
            ans += (temp_bit << i);
        }
        return ans;
    }
};

//2021.4.30
